package com.naizhuai.ui.components.listener;

import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.naizhuai.ui.components.SpinerPopWindow;

import java.util.List;

/**
 * popupwindow显示的ListView的item点击事件
 * Created by code_han on 2018/3/27.
 */

public class PopupItemListener<T> implements ListView.OnItemClickListener {
    private TextView tvText;
    private SpinerPopWindow<T> mSpinerPopWindow;
    private List<T> addTeamOperate;
    private PopupItemOnClickListener listener;

    public PopupItemListener(TextView tvText) {
        this.tvText = tvText;
    }

    public PopupItemListener(TextView tvText, SpinerPopWindow<T> mSpinerPopWindow, List<T> addTeamOperate) {
        this.tvText = tvText;
        this.mSpinerPopWindow = mSpinerPopWindow;
        this.addTeamOperate = addTeamOperate;
    }
    public void setOnPopUpItemListener(PopupItemOnClickListener listener){
        this.listener=listener;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        mSpinerPopWindow.dismiss();
        tvText.setText(addTeamOperate.get(position).toString());
        listener.onItemClick(parent,view,position,id);
    }

    public interface PopupItemOnClickListener{
        void onItemClick(AdapterView<?> parent, View view, int position, long id);

    }

}
